#!/bin/sh
# create an arch directory to build scl for use with a new 
# environment (hardward/compiler) 
#
# Usage: setup-arch
#
#

echo "Running the script: setup-arch - creates directory /proj/pdevel/scl3-1/arch-gnu-solaris"

cd /proj/pdevel/scl3-1
cp src/express/mkrules src/express/mkrules.arch-gnu-solaris

if (test ! -d arch-gnu-solaris) ; then
mkdir arch-gnu-solaris
fi

cd arch-gnu-solaris

if test -f scl_cf.h; then
mv -f scl_cf.h scl_cf.h.bak
fi
mv -f ../config/scl_cf.h scl_cf.h

if test ! -d lib; then
mkdir lib
fi
if test ! -d ofiles; then
mkdir ofiles
fi
if test ! -d bin; then
mkdir bin
fi

cd /proj/pdevel/scl3-1/config

#  

chmod +x mkProbe.current
cp mkProbe.current /proj/pdevel/scl3-1/arch-gnu-solaris/bin/mkProbe
chmod +x /proj/pdevel/scl3-1/arch-gnu-solaris/bin/mkProbe

cp sclbuild.current /proj/pdevel/scl3-1/arch-gnu-solaris/bin/sclbuild
chmod +x /proj/pdevel/scl3-1/arch-gnu-solaris/bin/sclbuild

cp setup-arch.current /proj/pdevel/scl3-1/arch-gnu-solaris/bin/setup-arch
chmod +x /proj/pdevel/scl3-1/arch-gnu-solaris/bin/setup-arch

cd /proj/pdevel/scl3-1/arch-gnu-solaris

if test ! -d testbuild; then
mkdir testbuild
fi

cd testbuild
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../arch_template/testbuild/Makefile Makefile

if test -f schema-loc; then
mv -f schema-loc schema-loc.bak
fi
cp ../../arch_template/testbuild/schema-loc schema-loc

#########
if test ! -d p21read; then
mkdir p21read
fi

cd p21read
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/testbuild/p21read/Makefile Makefile

if test -f testfile.step; then
mv -f testfile.step testfile.step.bak
fi
cp ../../../arch_template/testbuild/p21read/testfile.step testfile.step

cd ..
#########
if test ! -d scl2html; then
mkdir scl2html
fi

cd scl2html
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/testbuild/scl2html/Makefile Makefile
cd ..
#########
if test ! -d generate_express; then
mkdir generate_express
fi

cd generate_express
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/testbuild/generate_express/Makefile Makefile
cd ..
#########
if test ! -d tio; then
mkdir tio
fi

cd tio
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/testbuild/tio/Makefile Makefile

if test -f testfile.step; then
mv -f testfile.step testfile.step.bak
fi
cp ../../../arch_template/testbuild/tio/testfile.step testfile.step

cd ..
#########
if test ! -d treg; then
mkdir treg
fi

cd treg
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/testbuild/treg/Makefile Makefile
cd ..
#########
if test ! -d tstatic; then
mkdir tstatic
fi

cd tstatic
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/testbuild/tstatic/Makefile Makefile
cd ..
#########

cd /proj/pdevel/scl3-1/arch-gnu-solaris

if test ! -d Probes; then
mkdir Probes
fi

# In the Probes directory create the template-schema directory 
cd Probes
if test ! -d template-schema; then
mkdir template-schema
fi
cd ../

if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../arch_template/Makefile Makefile

if test -f sclprefixes.h.OrbixOstore; then
mv -f sclprefixes.h.OrbixOstore sclprefixes.h.OrbixOstore.bak
fi
cp ../arch_template/sclprefixes.h.OrbixOstore sclprefixes.h.OrbixOstore

if test -f sclprefixes.h.noOrbixOstore; then
mv -f sclprefixes.h.noOrbixOstore sclprefixes.h.noOrbixOstore.bak
fi
cp ../arch_template/sclprefixes.h.noOrbixOstore sclprefixes.h.noOrbixOstore

if test -f sclprefixes.h; then
mv -f sclprefixes.h sclprefixes.h.bak
fi
cp sclprefixes.h.noOrbixOstore sclprefixes.h


# move make_rules to our new arch location
if test -f make_rules; then
mv -f make_rules make_rules.bak
fi
mv -f ../arch_template/make_rules make_rules

#  In the ofiles directories:

#  1. Make the directories
cd ofiles
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../arch_template/ofiles/Makefile Makefile
if test ! -d probe-ui; then
mkdir probe-ui
fi
if test ! -d editorCore; then
mkdir editorCore
fi
if test ! -d utils; then
mkdir utils
fi
if test ! -d ivfasd; then
mkdir ivfasd
fi
if test ! -d dai; then
mkdir dai
fi
if test ! -d sdaiOrbix; then
mkdir sdaiOrbix
fi

#  2. 

cd probe-ui
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/ofiles/probe-ui/Makefile Makefile
cd ../editorCore
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/ofiles/editorCore/Makefile Makefile
cd ../utils
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/ofiles/utils/Makefile Makefile
cd ../ivfasd
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/ofiles/ivfasd/Makefile Makefile
cd ../dai
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/ofiles/dai/Makefile Makefile

cd ../sdaiOrbix
if test -f Makefile; then
mv -f Makefile Makefile.bak
fi
cp ../../../arch_template/ofiles/sdaiOrbix/Makefile Makefile

if test -f corbaIncludes.h; then
mv -f corbaIncludes.h corbaIncludes.h.bak
fi
cp ../../../arch_template/ofiles/sdaiOrbix/corbaIncludes.h corbaIncludes.h

if test -f sdaitypes.idl; then
mv -f sdaitypes.idl sdaitypes.idl.bak
fi
cp ../../../arch_template/ofiles/sdaiOrbix/sdaitypes.idl sdaitypes.idl

if test -f appinstance.idl; then
mv -f appinstance.idl appinstance.idl.bak
fi
cp ../../../arch_template/ofiles/sdaiOrbix/appinstance.idl appinstance.idl

if test -f p26sdai.idl; then
mv -f p26sdai.idl p26sdai.idl.bak
fi
cp ../../../arch_template/ofiles/sdaiOrbix/p26sdai.idl p26sdai.idl

cd ../../Probes/template-schema
if test -f Makefile.public; then
mv -f Makefile.public Makefile.public.bak
fi
if test -f Makefile.personal; then
mv -f Makefile.personal Makefile.personal.bak
fi
cp ../../../arch_template/Probes/template-schema/Makefile.public Makefile.public
mv -f ../../../arch_template/Probes/template-schema/Makefile.personal Makefile.personal
